<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class MusicsController extends AppController {

    var $layout = 'default';
    var $uses = array(
        'Music'
    );
    var $scripts = array('jquery-1.7.1.js', 'flowplayer-3.2.8.min.js','swfobject.js', 'slideshowNews.js','common.js');
    var $cacheAction = array(
        'index' => 120
    );
    function index($page = 1) {
        $this->set('title_for_layout', 'Giải trí - Nhạc');
        $page = array_key_exists('page', $this->params['named']) ? $this->params['named']['page'] : $page;
        $conditions = array(
            'Music.published' => 1,
        );
        $this->paginate = array(
            'fields' => array('Music.id, Music.title, Music.alias, Music.thumbnail, Singer.title'),
            'conditions' => $conditions,
            'limit' => 16,
            'order' => array(
                'Music.id' => 'DESC'
            ),
        );

        $data = $this->paginate('Music');
        $this->set('total', $this->params['paging']['Music']['count']);
        $this->set('data', $data);
        $this->set('limit_page', $this->paginate['limit']);
        $this->set('music_thumb_url_path', Configure::read('music_thumb_url_path'));
        
        $this->set('start_page', $page);
    }

    function detail($id) {
        $content = $this->Music->read(array('*'), $id);
        $this->Music->updateHit($id);
        $this->set('content', $content);
        $this->set('music_thumb_url_path', Configure::read('music_thumb_url_path'));
        $this->set('otherMusics', $this->Music->getOtherMusic($content['Music']['style_id'], $id));
        $this->set('music_url_path', Configure::read('music_url_path'));
        $this->set('title_for_layout', "Chi tiết &gt;&gt;{$content['Music']['title']}- Thời trang RED");


    }

}

?>
